home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
citydemo
/
c4i_rebind.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
4KB
|
168 lines
#ifndef lint
static char SccsId[]= "@(#)c4i_rebind.c V1.10 3/13/95";
#endif
/*------------------------------------------------------------------
| file name -- c4i_rebind.c
|
| functions Description
| --------- -----------
|
| InitDataTable Initialize the name:data table for rebinding.
| RebindData Rebinds DV-Draw variables to Application Data.
| rebind Local. Slectively rebinds VDPs to application buffers.
| TermDataTable Cleans up the name:data table.
|
| GetVdp Returns the vdp associated with the object.
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "VOstd.h"
#include "Tfundecl.h"
#include "c4i_vars.h"
#include "c4i_data.h"
#include "VGfundecl.h"
#include "VTfundecl.h"
#include "c4i_fundecl.h"
/***************** Begin Function Declarations *************/
LOCAL ADDRESS rebind V_P_((OBJECT vd_obj, ADDRESS vdp, ADDRESS args));
LOCAL ADDRESS return_vdp V_P_((OBJECT vd_obj, ADDRESS vdp, ADDRESS args));
CHAR *VIstrclone V_P_((char*)); /* Internal function: allocates & copies a string */
/***************** End Function Declarations *************/
/*-----------------------------------------------------------------
|
| InitDataTable
| Initialize the Data Table. The Data Table is a symbol table of
| variable names and their data buffer. This table is used by
| DV-Tools to rebind DV-Draw variables to application data.
*/
void InitDataTable
V_P_ ((void))
{
INT i;
/* Create the symbol table */
DataTable = VTstcreate ("Data Name and Info", (VTSTCOMPAREFUNPTR)NULL);
/* Make entries for the name buffer pairs defined by DataTable
| in c4i_data.c
*/
for (i = 0; i < MAX_APP_VARS; i++)
{
(VOID) VTstsninsert (DataTable,
VIstrclone (DataInfo[i].varname),
(INT *) & DataInfo[i]);
}
}
/*-----------------------------------------------------------------
|
| RebindData
| Traverses the view's vdps, checking to see if they need to
| be rebound to real-time data buffers.
|
*/
void
RebindData (view)
VIEW view;
{
/* Rebind all the vdps that match the table of real-time data.
| Get the drawing from the view and then all rebind() for
| all the variables.
*/
(VOID) TobForEachVdp (TviGetDrawing (view), rebind, (ADDRESS) NULL);
}
/*-----------------------------------------------------------------
|
| rebind
| Gets the vdp's name, if it matches one in the DataTable, rebind
| the buffer to the real-time buffer.
*/
/* ARGSUSED */
LOCAL ADDRESS
rebind (vd_obj, vdp, args)
OBJECT vd_obj;
ADDRESS vdp;
ADDRESS args;
{
CHAR *varname;
SYMNODE node;
DATA_INFO *data_info;
/* Get the vdp's name */
varname = VGvdvarname (vdp);
/* See if the name is in the Table of Application Variables */
node = VTstkeyfind (DataTable, varname);
if (node)
{
/* Rebind the data to the application buffer */
data_info = (DATA_INFO *) VTsnvalue (node);
(VOID) TvdPutBuffer (vdp, data_info->bufptr);
}
return NULL;
}
/*-----------------------------------------------------------------
|
| TermDataTable
*/
void TermDataTable
V_P_ ((void))
{
CHAR *varname;
SYMNODE node;
/* Destroy the strings cloned in the table */
while (VTstlen (DataTable) > 0)
{
node = VTstsnget (DataTable, 0);
varname = VTsnkey (node);
S_FREE (varname);
VTstsnremove (DataTable, node);
}
/* Destroy the table itself */
VTstdestroy (DataTable);
}
/*------------------------------------------------------------------
|
| GetVdp
| Uses TobForEachVdp to return object's vdp. This function assumes
| the object only has one vdp.
*/
ADDRESS
GetVdp (obj)
OBJECT obj;
{
/* Call return_vdp() for each vdp, this function assumes only one vdp */
return (VARDESC) TobForEachVdp (obj, return_vdp, (ADDRESS) NULL);
}
/*-----------------------------------------------------------------
|
| return_vdp
| Returns the passed in vdp, this funciton is called from
| inside of TobForEachVdp().
*/
/* ARGSUSED */
LOCAL ADDRESS
return_vdp (vd_obj, vdp, args)
OBJECT vd_obj;
ADDRESS vdp;
ADDRESS args;
{
return vdp;
}